package dome7;
class OuterClass{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;
    class InterClass{//内部类
        public int data1 = 111;
        public int data4 = 4;
        public static final int data5 = 5;//变成常量,加static+final
        private int data6 = 6;
        public void test(){
            System.out.println("InterClass::test()");
            System.out.println(OuterClass.this.data1);//外部类类名.this.data1
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);

        }
    }
    public void test(){
        InterClass interClass = new InterClass();
        System.out.println("========================");
        System.out.println(interClass.data4);
        System.out.println(interClass.data5);
        System.out.println(interClass.data6);


        System.out.println("OuterClass::test()");
    }
}
class Out{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;
    static class InterClass{//静态内部类
       public int data4 = 4;
       public static int data5 = 5;
       private int data6 = 6;
       public void test(){
           Out out = new Out();
           System.out.println(out.data1);//静态内部类调用外部类
           System.out.println(data2);
           System.out.println(out.data3);
           System.out.println(data4);
           System.out.println(data5);

           System.out.println("InterClass::test()");
       }
    }
    public void test(){
        System.out.println("Out::test()");
    }
}
interface  IA{//匿名内部类
    void test();
}
public class Test {
    //局部内部类
    public void Func(){
        class AA{
            public int a;
        }
        AA aa = new AA();
        System.out.println(aa.a);
    }
    public static void main(String[] args) {
        IA a = new IA(){
            //匿名内部类
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法");
            }
        };
        a.test();
        new IA(){
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法");
            }
        }.test();

        Out.InterClass interClass = new Out.InterClass();//静态的方法
        interClass.test();
        Out out = new Out();
        out.test();

        System.out.println("++++++++++");

        OuterClass outerClass = new OuterClass();
       // OuterClass.InterClass interClass = outerClass.new InterClass();
        interClass.test();
        outerClass.test();

    }
}
